package com.bw.task.adapter;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import org.jetbrains.annotations.NotNull;

public class MySearchView extends RecyclerView {
    private  boolean isFull = false;
    public MySearchView(@NonNull @NotNull Context context) {
        super(context);
    }

    public MySearchView(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MySearchView(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthSpec, int heightSpec) {
        super.onMeasure(widthSpec, heightSpec);
        if (isFull){
            //  大小除以二            包裹住
            int hight = View.MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2, MeasureSpec.AT_MOST);
            super.onMeasure(widthSpec,hight);
        }else {
            super.onMeasure(widthSpec,300);
        }
    }

    public void setFull(boolean full) {
        isFull = full;
        requestLayout();
    }

}
